/*
* Copyright (C) 2020 ~ 2024 chaigec All Rights Reserved.
*
* Author:     chaigec <chaigec@163.com>
* Maintainer: chaigec <chaigec@163.com>

 * Use of this source code is governed by MIT license that can be found in the
 * LICENSE file in the root of the source tree. All contributing project authors
 * may be found in the AUTHORS file in the root of the source tree.
*/

#ifndef MK_RTSP_SUB_SESSION_H
#define MK_RTSP_SUB_SESSION_H
#include "MkRtspUtil.h"
#include "MkSdp/MkSdp.h"
#include "MkRtp/MkRtpUtil.h"

class CMkRtpUdpServer;
class MkApi CMkRtspSubSession
{
public:
    CMkRtspSubSession(const MkString& RtpRemoteHost, const MkVideoAudioSetCallback& SetCb);
    ~CMkRtspSubSession();

    Uint32 SetSdpMedia(const CMkSdpMedia& SdpMedia);
    void SetRtpUdpServer(CMkRtpUdpServer* pRtpUdpServer) { m_RtpUdpServer = pRtpUdpServer; }
    Uint16 GetRtpLocalUdpPort();
    const MkString& GetRtpRemoteHost() const { return m_RtpRemoteHost; }
    void SetTimeOut(Uint32 Second) { m_TimeOut = Second; m_SetUpTime = NowMkTime; }
    void SetRtpRemotePort(Uint16 RtpPort) { m_RtpRemotePort = RtpPort; }
    BOOL IsNotSetUp() const { return m_SetUpTime.IsEmpty(); }
    const MkString& GetUri()const { return m_Uri; }
    void SetUri(const MkString& Uri) { m_Uri = Uri; }
    const MkCodecType& GetCodec() const { return m_Codec; }
    CMkRtpUdpServer* GetRtpUdpServer() { return m_RtpUdpServer; }
    void SetSsrc(const Uint32& Ssrc) { m_Ssrc = Ssrc; }
    const Uint32& GetSsrc() const { return m_Ssrc; }
    const CMkSdpMedia& GetSdpMedia() const { return m_SdpMedia; }
    const Uint8& GetPayloadType()const { return m_PayloadType; }
    void SetPayload(const Uint8& Payload) { m_PayloadType = Payload; }
    Uint32 GetSeqNumber() { return m_SeqNumber++; }
    Uint32 GetCurSeqNumber() const { return m_SeqNumber; }
    Uint32 SendRtpPacket(const CMkRtpPacket& RtpPacket);
private:
    MkCodecType             m_Codec;
    Uint32                  m_Ssrc;
    Uint32                  m_SeqNumber;
    MkString                m_RtpRemoteHost;
    Uint16                  m_RtpRemotePort;
    CMkSdpMedia             m_SdpMedia;
    MkString                m_Uri;
    CMkTime                 m_SetUpTime;
    Uint32                  m_TimeOut;
    CMkRtpUdpServer*        m_RtpUdpServer;
    double                  m_PlayStartTime;
    double                  m_PlayEndTime;
    CMkTime                 m_AbsStartTime;
    CMkTime                 m_AbsEndTime;
    MkString                m_Mikey;
    MkVideoAudioSetCallback m_VideoAudioSetCb;

    Uint8                   m_PayloadType;
    //Uint32                  m_H264ProfileLevelId;
    //Uint32                  m_H264PacketMode;


    MkString                m_Session;
    MkString                m_TimeOutTimer;
};



#endif